home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
Mops 2.7
/
Mops source
/
More classes
/
Sets
< prev
next >
Wrap
Text File
|
1991-09-09
|
2KB
|
89 lines
\ Some experimentation.
: ET! immediate
$ 201E w, \ POP.L D0
$ 41BC w, \ CHK #nn,D0
w, \ (nn)
$ 1480 w, \ MOVE.B D0,(A2)
;
0 value X
0 value LO
0 value HI
: (DO_ET)
typecnt 1 - -> x
" :m SIZE: [ x ] lit ;m" evaluate
" :m PUT: [ x ] et! ;m" evaluate ;
' (do_ET) -> do_ET
:class ENUM-TYPE super{ byte } \ Generic supertype for all enumerated
\ types.
:m GET: ^base c@ ;m
:m ->: chksame c@ ^base c! ;m
;class
: IS_RANGE
-> hi -> lo hi lo - -> x
" :m RANGE: [ lo ] lit [ hi ] lit ;m" evaluate
" :m PUT: [ lo ] lit - [ x ] et! ;m" evaluate
" :m GET: ^base c@ [ lo ] lit + ;m" evaluate ;
:class RANGE super{ byte }
:m ->: chksame c@ ^base c! ;m
;class
0 value SZ
0 value LN
: ELEMENT_IS
" SIZE:" here place here hash
' \ ^class
findm nip execute -> sz
sz 1- 3 >> 1+ -> ln
ln ^class dfa w+! \ Allocate the space
\ Now we define the methods:
" :m SIZE: [ sz ] lit ;m" evaluate
" :m LEN: [ ln ] lit ;m" evaluate ;
:class SET super{ object }
:m +: ^base swap bset ;m
:m -: ^base swap breset ;m
:m IN?: inline{ obj swap btest}
^base swap btest ;m
:m CLASSINIT:
len: [self]
for 0 ^base i + c! next ;m
;class
\ endload
:class DAY super{ enum-type }
type{ sunday monday tuesday wednesday thursday friday saturday }
;class
:class DAYS super{ set } element_is day
;class
day TODAY
day YESTERDAY
days WEEKEND saturday +: weekend sunday +: weekend
:class RRR super{ range } 100 200 is_range
;class